function main(params) {
    debugger;

    // 兼容的参数获取方式
    var id = params.id.value;
    var verifyId = params.verify_id.value;
    var litigantName = params.litigant_name.value;
    var modifyId = params.modify_id.value;
    var litigantBigTypeCode = params.litigant_big_type_code.value;
    var verifyTypeId = params.verify_type_id.value;

    var litigantInfo = {
        id: id,
        verifyId: verifyId,
        litigantName: litigantName,
        modifyId: modifyId,
        litigantBigTypeCode: litigantBigTypeCode,
        verifyTypeId: verifyTypeId
    };

    // 页面ID映射
    var pageIdMap = {
        "1": "1980921894041587712",
        "2": "1980921894041587712",
        "default": "1980921894041587712"
    };

    if (litigantInfo.verifyTypeId == "0") {
        openDialog(this, litigantInfo);
    } else {
        var pageId = pageIdMap[litigantInfo.litigantBigTypeCode] || pageIdMap.default;
        openPage(this, litigantInfo, pageId);
    }
}

/**
 * 打开页面
 */
function openPage(self, litigantInfo, pageId) {
    var rootPageElement = findRootPageElement(self);

    if (!rootPageElement) {
        console.error("未找到根页面元素");
        return;
    }

    rootPageElement.$$open(pageId, "PAGE", {
        title: "编辑审核",
        cached: false,
        backStep: 1,
        showHeader: true,
        extraParams: {
            modifyId: litigantInfo.modifyId,
            "number_input_79fwj8": litigantInfo.id,
            "verifyId": litigantInfo.verifyId,
            "text_input_8x3kre": litigantInfo.litigantName
        }, // 部件弹窗的回调（对表单部件有效）
        callback: (actionType) => {
            handlePageCallback(actionType,self);
        }
    });

}

/**
 * 处理页面回调
 */
function handlePageCallback (actionType,self){
    debugger
    refreshListData(self);
}

/**
 * 查找根页面元素
 */
function findRootPageElement(element) {
    var currentElement = element;
    while (currentElement) {
        if (currentElement.getPageInfo && currentElement.goHistory) {
            return currentElement;
        }
        currentElement = currentElement.$parent;
    }
    return null;
}

/**
 * 打开审核对话框
 */
function openDialog(self, litigantInfo) {
    var dialogConfig = {
        linkAction: {
            moduleModalTitle: "审核",
            moduleModalPosition: "middle",
            moduleModalSize: "custom",
            moduleModalWidth: 600,
            moduleModalHeight: 400,
            moduleOpenMask: true,
            isDetail: false
        },
        callback: function(actionType, params) {
            handleDialogCallback(actionType, params, self);
        },
        params: {
            "number_input_79fwj8": litigantInfo.id,
            documentNo: litigantInfo.verifyId,
            "text_input_8x3kre": litigantInfo.litigantName
        }
    };

    api.MODULE_DIALOG(self, "NORMAL_FORM", "0de28976-9fd3-483d-89f8-1ece4ae5f1e7", dialogConfig);
}

/**
 * 处理对话框回调
 */
function handleDialogCallback(actionType, params, context) {
    debugger;
    console.log(actionType, params);

    if (actionType !== 'form-save') return;

    var formData = params.result && params.result.t_34d0cbb1d44f4c0d8d499ae7a652c23c;
    if (!formData) {
        console.error("未找到表单数据");
        return;
    }

    var validFlag = formData.radio_c2kieg;
    var id = formData.number_input_79fwj8;

    var deleteFlag = validFlag == '1' ? 0 : -1;

    var updateQuery = "UPDATE('t_d56d1837bd17409ab2b9de2fe7b9952f',QUERY_EQ('id'," + id + "),'', ['delete_flag'," + deleteFlag + ", 'valid_flag', " + validFlag + ",'credit_score',100])";

    api.EXEC_FORMULA(updateQuery).then(function(res) {
        console.log("更新成功:", res);
        refreshListData(context);
    }).catch(function(error) {
        console.error("更新失败:", error);
    });
}

/**
 * 刷新列表数据
 */
function refreshListData(context) {
    try {
        var pageListEle = context.$$("page_widget_list_6dwsms");
        if (pageListEle) {
            var listRenderView = pageListEle.$$getRenderElement();
            if (listRenderView) {
                var currentListEle = listRenderView.$$getListElement();
                if (currentListEle && currentListEle.$$refreshData) {
                    currentListEle.$$refreshData();
                    return;
                }
            }
        }
        console.warn("刷新列表数据失败：未找到列表元素或刷新方法");
    } catch (error) {
        console.error("刷新列表数据时发生错误:", error);
    }
}
